package com.example.hdwx.myapplication.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.example.hdwx.myapplication.R;
import com.example.hdwx.myapplication.eneity.found_eneitys.FoundShareEneity;
import com.example.hdwx.myapplication.untils.ImageLoaderUtils;

import java.util.List;

/**
 * Created by hudongwx on 17-2-13.
 */

public class FoundShareAdapter extends RecyclerView.Adapter<FoundShareAdapter.FoundShareHolder>{
    Context context;
    List<FoundShareEneity> data;

    public FoundShareAdapter(Context context, List<FoundShareEneity> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public FoundShareHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.found_item_share_layout,parent,false);
        return new FoundShareHolder(view);
    }

    @Override
    public void onBindViewHolder(FoundShareHolder holder, int position) {
        FoundShareEneity eneity = data.get(position);
        holder.textView.setText(eneity.getNickName());
        ImageLoaderUtils.setImageRriusLoader(context,eneity.getImageUrl(),holder.imageView);
        holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO 关注点击事件
            }
        });
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class FoundShareHolder extends RecyclerView.ViewHolder{
        ImageView imageView;
        TextView textView;
        RelativeLayout relativeLayout;
        public FoundShareHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.found_share_img);
            textView = (TextView) itemView.findViewById(R.id.found_share_text);
            relativeLayout = (RelativeLayout) itemView.findViewById(R.id.found_share_follow);
        }
    }
}
